package net.lab1024.sa.admin.module.aneswork.schedule;

import net.lab1024.sa.admin.module.aneswork.schedule.domain.entity.StudentScheduleEntity;
import net.lab1024.sa.admin.module.aneswork.schedule.domain.form.StudentScheduleAddForm;
import net.lab1024.sa.admin.module.aneswork.schedule.domain.form.StudentScheduleQueryForm;
import net.lab1024.sa.admin.module.aneswork.schedule.domain.form.StudentScheduleUpdateForm;
import net.lab1024.sa.admin.module.aneswork.schedule.domain.vo.StudentScheduleVO;
import net.lab1024.sa.base.common.domain.ValidateList;
import net.lab1024.sa.base.module.support.apiencrypt.annotation.ApiDecrypt;
import net.lab1024.sa.base.module.support.apiencrypt.annotation.ApiEncrypt;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * 轮转安排 Controller
 *
 * @Author fwj
 * @Date 2025-04-29 15:32:59
 * @Copyright 1.0
 */

@RestController
@Tag(name = "轮转安排")
public class StudentScheduleController {

    @Resource
    private StudentScheduleService studentScheduleService;

    @ApiDecrypt
    @ApiEncrypt
    @Operation(summary = "分页查询 @author fwj")
    @PostMapping("/studentSchedule/queryPage")
    public ResponseDTO<PageResult<StudentScheduleVO>> queryPage(@RequestBody @Valid StudentScheduleQueryForm queryForm) {
        return ResponseDTO.ok(studentScheduleService.queryPage(queryForm));
    }

    @ApiDecrypt
    @ApiEncrypt
    @Operation(summary = "查询全部 @author fwj")
    @PostMapping("/studentSchedule/list")
    public ResponseDTO<List<StudentScheduleVO>> list(@RequestBody @Valid StudentScheduleVO queryForm) {
        return ResponseDTO.ok(studentScheduleService.list(queryForm));
    }

    @ApiDecrypt
    @ApiEncrypt
    @Operation(summary = "添加 @author fwj")
    @PostMapping("/studentSchedule/add")
    public ResponseDTO<String> add(@RequestBody @Valid StudentScheduleAddForm addForm) {
        return studentScheduleService.add(addForm);
    }

    @ApiDecrypt
    @ApiEncrypt
    @Operation(summary = "更新 @author fwj")
    @PostMapping("/studentSchedule/update")
    public ResponseDTO<String> update(@RequestBody @Valid StudentScheduleUpdateForm updateForm) {
        return studentScheduleService.update(updateForm);
    }

    @ApiDecrypt
    @ApiEncrypt
    @Operation(summary = "批量删除 @author fwj")
    @PostMapping("/studentSchedule/batchDelete")
    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Integer> idList) {
        return studentScheduleService.batchDelete(idList);
    }

    @ApiDecrypt
    @ApiEncrypt
    @Operation(summary = "单个删除 @author fwj")
    @GetMapping("/studentSchedule/delete/{id}")
    public ResponseDTO<String> batchDelete(@PathVariable Integer id) {
        return studentScheduleService.delete(id);
    }
}
